#include <stdio.h>

#include <algorithm>

using namespace std;

#define MAXN (1000 + 5)
int n;

int A[MAXN][MAXN];
int dp[MAXN][MAXN];

void Read() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      scanf("%d", &A[i][j]);
    }
}

int dp_Solve() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == 0 && j == 0) {
        dp[i][j] = A[i][j];
      } else if (i == 0) {
        dp[i][j] = dp[i][j - 1] + A[i][j];
      } else if (j == 0) {
        dp[i][j] = dp[i - 1][j] + A[i][j];
      } else {
        dp[i][j] = A[i][j] + max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  return dp[n - 1][n - 1];
}

int GreedySolve() {
  int ans = A[0][0];
  int i = 0;
  int j = 0;
  while (i < n && j < n) {
    int down = A[i][j + 1];
    int right = A[i + 1][j];

    if (down > right) {
      ans += down;
      j++;
    } else {
      ans += right;
      i++;
    }
  }
  return ans;
}

int main() {
//   freopen("in2.txt", "r", stdin);
  Read();
  int ans = dp_Solve();
  printf("%d\n", ans);
  return 0;
}